import 'package:tiktokadult/hj_utils/api_service/mine_service.dart';
import 'package:tiktokadult/tools_base/base_list_controller.dart';

class MinePublishSubLogic extends BaseListController {
  int status = 0;

  MinePublishSubLogic({required this.status});

  @override
  fetchPageData({bool isRefresh = true, bool needLoading = false}) async {
    if (isRefresh) {
      page = 1;
    }
    if (needLoading) {
      isLoading = true;
      update();
    }
    final result = await MineService.fetchMyPublishes(page: page, status: status);
    isLoading = false;
    if (isRefresh) {
      refreshController.refreshCompleted();
      dataSource.clear();
    }
    if (result.hasNext ?? false) {
      refreshController.loadComplete();
    } else {
      refreshController.loadNoData();
    }
    dataSource.addAll(result.list ?? []);
    page += 1;
    update();
  }
}
